<?php
/**
 * Created by PhpStorm.
 * User: Duck
 * Create time: 2016/12/21 9:56
 */

namespace D\Controller;
use Common\Controller\BaseController;

class ClassTeachController extends BaseController{
    public function show(){
        $tc=M('teachers')->select();
        $this->assign('tc',$tc);
        $this->display();
    }
    public function getTeacher(){
        if(!empty($_POST['tname'])){
            $res=M('teachers')->where(array('tname'=>$_POST['tname']))->select();
        }
        if(!empty($_POST['class'])){
            $res=M('teachers')->where(array('tclass'=>$_POST['class']))->select();
        }
        $this->ajaxReturn($res);
    }
    public function edit(){
        if(D('teachers')->create()){
            if(D('teachers')->save()){
                $res='保存成功';
            }else{
                $res='保存失败';
            }
        }else{
            $res='数据错误';
        }
        $this->ajaxReturn($res);
    }
}